<!-- 仓库设置 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage">

    </ex_super_table_page>

    <dialog_detail_desc ref="dialog_detail_desc" url="/oms-api/base/OmsBaseWarehouseRpc/detail.json"
      :descOption="descOption" />
  </div>
</template>
<script>


import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'oms>warehouse_setting'

export default {
  title: "title_Warehouse_manage",
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: {  },
  data() {
    return {
      submitUrl: '/oms-api/base/OmsBaseWarehouseRpc/insertOrUpdate.json',
      detailUrl: '/oms-api/base/OmsBaseWarehouseRpc/detail.json',
      visible: false,

      option: {
        search: {
          model: [
            {
              label: "label_warehouse_type", key: "type", type: 'select', enum: 'WarehouseTypeEnum',
            },
            {
              label: "label_warehouse_place",
              key: "position",
              type: 'select',
              enum: 'BaseWarehousePositionEnum',
            },
            {
              label: "label_operation_type",
              key: "manageType",
              type: 'select',
              enum: 'WarehouseManageTypeEnum',
            },
            {
              label: "label_status", key: "status", type: 'select', enum: 'IsAvailableStatusEnum',
            },
            { label: "label_warehouse_code", key: "code", type: 'input', },
            { label: "label_warehouse_name", key: "name", type: 'input', },
            {
              label: "label_start_time",
              key: "createDateStart",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "label_end_time",
              key: "createDateEnd",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        action: [
          {
            label: 'label_new_warehouse', attrs: { icon: "el-icon-plus" },
            auth:'oms_warehouse_setting_edit',
            click: () => {
              this.$router.push({ path: '/page/oms/warehouse/warehouse_operate', query: { emitKey } });
            }
          },
        ],

        table: {
          url: "/oms-api/base/OmsBaseWarehouseRpc/selectPage.json",
          attrs: {},
          model: [
            { key: 'code', label: 'label_warehouse_code', 'min-width': 150, 'show-overflow-tooltip': true, },
            { key: 'name', label: 'label_warehouse_name', 'min-width': 150, 'show-overflow-tooltip': true, },
            {
              key: 'type',
              label: 'label_warehouse_type',
              formatter: (r, c, v, i) => this.$enumShow(v, "WarehouseTypeEnum"),
              width: 150,
            },
            {
              key: 'manageType',
              label: 'label_operation_type',
              formatter: (r, c, v, i) => this.$enumShow(v, "WarehouseManageTypeEnum"),
              width: 150,
            },
            { key: 'contacter', label: 'label_commander', 'min-width': 120, 'show-overflow-tooltip': true, },
            { key: 'phone', label: 'label_contact_phone', 'min-width': 120, 'show-overflow-tooltip': true, },
            { key: 'streetAddress1', label: 'label_warehouse_address', 'min-width': 200, 'show-overflow-tooltip': true, },
            { key: 'postcode', label: 'label_zip_code', 'min-width': 80, 'show-overflow-tooltip': true, },
            { key: 'creator', label: 'label_create_user', 'min-width': 120, 'show-overflow-tooltip': true, },
            {
              key: 'gmtCreate',
              label: 'label_create_time',
              'min-width': 120,
              'show-overflow-tooltip': true,
              formatter: (r, c, v, i) => this.$dateFormat(v)
            },
            {
              type: 'operate', width: 160, operate: [
                {
                  type: 'more',
                  items: [
                    { label: 'label_view_detail', click: (row) => this.clickDetail(row) },
                    {
                      label: 'label_edit_warehouse',
                      auth:'oms_warehouse_setting_edit',
                      click: (row) => {
                        this.$router.push({ path: '/page/oms/warehouse/warehouse_operate', query: { "id": row["id"], edit: true, emitKey } });

                      }
                    },
                  ]
                },
                {
                  label: 'label_delete',
                  auth:'oms_warehouse_setting_delete',
                  type: "confirm-button",
                  url: '/oms-api/base/OmsBaseWarehouseRpc/delete.json',
                  message: 'text_confirm_sure_delete',
                  buttonClass: "button_text_danger",
                  confirmButtonType: 'danger',
                  params: (row) => {
                    return { "id": row["id"] }
                  },
                  done: ['reload', 'tip',()=>{
                    this.$store.dispatch('setAllWarehouseAction')
                  }]
                },
              ]
            },
          ],
        }
        ,

      },


      descOption:{
        model: [
          { key: 'code', label: 'label_warehouse_code' },
          { key: 'name', label: 'label_warehouse_name', },
          { key: 'type', label: 'label_warehouse_type', formatter: (r,c,v) => this.$enumShow(v, "WarehouseTypeEnum") },
          { key: 'status', label: 'label_status', formatter: (r,c,v) => this.$enumShow(v, "IsAvailableStatusEnum") },
          { key: 'manageType', label: 'label_operation_type', formatter: (r,c,v) => this.$enumShow(v, "WarehouseManageTypeEnum") },
          { key: 'position', label: 'label_warehouse_place',formatter: (r,c,v) => this.$enumShow(v, "BaseWarehousePositionEnum") },
          { key: 'countryName', label: 'label_country' },
          { key: 'province', label: 'label_province', },
          { key: 'city', label: 'label_city' },
          { key: 'county', label: 'label_region', },
          { key: 'address', label: 'label_detail_address', },
          { key: 'contacter', label: 'label_contact', },
          { key: 'phone', label: 'label_contact_phone', },
          { key: 'postcode', label: 'label_zip_code', },
          { key: 'totalArea', label: 'label_whole_warehouse_proportion',formatter: (r, c, v, i) => `${v}m³`},
          { key: 'usableArea', label: 'label_usable_warehouse_proportion',formatter: (r, c, v, i) => `${v}m³` },
          { key: 'longitude', label: 'label_lon', },
          { key: 'latitude', label: 'label_lat', },
          { key: 'creator', label: 'label_create_user', },
          { key: 'gmtCreate', label: 'label_create_time', formatter: (r, c, v, i) => this.$dateFormat(v) },
        ],
      },
    };
  },
  methods: {
    clickDetail(row) {
      let title = this.$formatNameCode(this.$tt('label_warehouse_detail'), row.code)
      this.$refs['dialog_detail_desc'].show({ params: { id: row.id }, title })
    },
  }
};

</script>
<style></style>
